package leetcode_121_140;

import DataStructure.Node;
import org.junit.Test;
import utils.TreeNode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test7 {
    @Test
    // 买卖股票的最佳时机
    public void test121() {
        int[] prices={7,1,5,3,6,4};
        System.out.println(new maxProfit_121().maxProfit(prices));
    }

    @Test
    // 买卖股票的最佳时机 II
    public void test122() {
        int[] prices={7,1,5,3,6,4};
        System.out.println(new maxProfit_121().maxProfit2(prices));
    }

    @Test
    // 买卖股票的最佳时机Ⅲ
    public void test123() {
        int[] prices={7,1,5,3,6,4};
        System.out.println(new maxProfit_121().maxProfit3(prices));
    }

    @Test
    //二叉树中的最大路径和
    public void test124() {
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(2);
        TreeNode treeNode3=new TreeNode(2);

        TreeNode treeNode4=new TreeNode(3);
        TreeNode treeNode5=new TreeNode(3);

        TreeNode treeNode6=new TreeNode(4);
        TreeNode treeNode7=new TreeNode(-4);

        treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;

        treeNode2.left=treeNode4;
        treeNode2.right=treeNode5;

        treeNode3.left=treeNode6;
        treeNode3.right=treeNode7;

        System.out.println(new maxPathSum_124().maxPathSum(treeNode7));
    }

    @Test
    //验证回文串
    public void test125() {
        //String s = "A man, a plan, a canal: Panama";
        String s = ".,";
        System.out.println(new isPalindrome_125().isPalindrome(s));
    }

    @Test
    //单词接龙2
    public void test126() {
        String beginWord = "hit", endWord = "cog";
        String[]wordList = {"hot","dot","dog","lot","log","cog"};
        System.out.println(new findLadders_126().findLadders2(beginWord,endWord, Arrays.asList(wordList)));
    }

    @Test
    //单词接龙
    public void test127() {
        String beginWord = "hit", endWord = "cog";
        String[]wordList = {"hot","dot","dog","lot","log","cog"};
        System.out.println(new findLadders_126().ladderLength(beginWord,endWord, Arrays.asList(wordList)));
    }

    @Test
    //验证回文串
    public void test128() {
        int nums[] = {3,1,2};
        System.out.println(new longestConsecutive_128().longestConsecutive(nums));
    }

    @Test
    //求根节点到叶节点数字之和
    public void test129() {
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(2);
        TreeNode treeNode3=new TreeNode(2);

        TreeNode treeNode4=new TreeNode(3);
        TreeNode treeNode5=new TreeNode(3);

        TreeNode treeNode6=new TreeNode(4);
        TreeNode treeNode7=new TreeNode(4);

        //treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;

//        treeNode2.left=treeNode4;
//        treeNode2.right=treeNode5;
//
//        treeNode3.left=treeNode6;
//        treeNode3.right=treeNode7;

        System.out.println(new sumNumbers_129().sumNumbers(treeNode1));
    }

    @Test
    //被围绕的区域
    public void test130() {
        char board[][] = {
                {'X','X','X','X'},
                {'X','O','O','X'},
                {'X','X','O','X'},
                {'X','O','O','X'}
        };
        new solve_130().solve(board);
    }

    @Test
    //验证回文串
    public void test131() {
        String s="aab";
        System.out.println(new partition_131().partition(s));
    }

    @Test
    //验证回文串2
    public void test132() {
        String s="aaabaa";
        System.out.println(new minCut_132().minCut(s));
    }

    @Test
    // 克隆图
    public void test133() {
        ArrayList<Node>list1=new ArrayList<>();
        ArrayList<Node>list2=new ArrayList<>();
        ArrayList<Node>list3=new ArrayList<>();
        ArrayList<Node>list4=new ArrayList<>();
        Node node1=new Node(1,list1);
        Node node2=new Node(2,list2);
        Node node3=new Node(3,list3);
        Node node4=new Node(4,list4);

        list1.add(node2);
        list1.add(node4);
        list2.add(node1);
        list2.add(node3);
        list3.add(node2);
        list3.add(node4);
        list4.add(node1);
        list4.add(node3);
        Node a=new cloneGraph_133().cloneGraph(node1);
    }

    @Test
    //加油站
    public void test134() {
        int []gas = {1,2,3,4,5}, cost = {3,4,5,1,2};
        System.out.println(new canCompleteCircuit_134().canCompleteCircuit(gas,cost));
    }

    @Test
    //发糖果
    public void test135() {
        int []ratings ={1,2,2};
        System.out.println(new candy_135().candy(ratings));
    }

    @Test
    // 只出现一次的数字
    public void test136() {
        int []nums ={1,2,2};
        System.out.println(new singleNumber_136().singleNumber(nums));
    }
    @Test
    // 只出现一次的数字2
    public void test137() {
        int []nums ={1,2,2,2};
        System.out.println(new singleNumber_136().singleNumber3(nums));
    }

    @Test
    //拷贝随机链表
    public void test138() {
        RandomList.Node node1 =new RandomList.Node(7);
        RandomList.Node node2 =new RandomList.Node(13);
        RandomList.Node node3 =new RandomList.Node(11);
        RandomList.Node node4 =new RandomList.Node(10);
        RandomList.Node node5 =new RandomList.Node(1);

        node1.next=node2;

        node2.next=node3;
        node2.random=node1;

        node3.next=node4;
        node3.random=node5;

        node4.next=node5;
        node4.random=node3;

        node5.random=node1;

        System.out.println(new copyRandomList_138().copyRandomList(node1));
    }

    @Test
    // 单词拆分
    public void test139() {
//        String s = "catsandogcat";
//        List<String> wordDict =new ArrayList<>();
//        wordDict.add("cats");
//        wordDict.add("dog");
//        wordDict.add("sand");
//        wordDict.add("and");
//        wordDict.add("cat");
//        wordDict.add("an");
        //        String s = "aaab";
//        List<String> wordDict =new ArrayList<>();
//        wordDict.add("a");
//        wordDict.add("aa");
//        wordDict.add("aaa");

        String s = "pineapplepenapple";
        List<String> wordDict =new ArrayList<>();
        wordDict.add("pine");
        wordDict.add("apple");
        wordDict.add("pen");
        wordDict.add("applepen");
        wordDict.add("pineapple");

        System.out.println(new wordBreak_139().wordBreak(s,wordDict));
    }

    @Test
    // 单词拆分2
    public void test140() {
        String s = "pineapplepenapple";
        List<String> wordDict =new ArrayList<>();
        wordDict.add("pine");
        wordDict.add("apple");
        wordDict.add("pen");
        wordDict.add("applepen");
        wordDict.add("pineapple");

//        String s = "catsandogcat";
//        List<String> wordDict =new ArrayList<>();
//        wordDict.add("cats");
//        wordDict.add("dog");
//        wordDict.add("sand");
//        wordDict.add("and");
//        wordDict.add("cat");
//        wordDict.add("an");
        System.out.println(new wordBreak_140().wordBreak(s,wordDict));
    }
}

